﻿
<!--
https://github.com/netnr
https://gitee.com/netnr
https://www.netnr.com
https://zme.ink
-->


<!DOCTYPE html>
<html>
<head>

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <link rel='shortcut icon' href='/favicon.ico' type='image/x-icon' />


    <title>ZeroTier 脚本服务</title>

    <meta name="keywords" content="netnr NET牛人 ZeroTier" />
    <meta name="description" content="Script Services ZeroTier 管理" />

</head>
<body>
<link href='https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css' rel='stylesheet' />
<link href='https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css' rel='stylesheet' />
<script src='https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js'></script>
<script src='https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js'></script>
<script src='https://cdn.jsdelivr.net/npm/jzjs@2.0.2/2.0.2/jz.min.js'></script>
<link href='https://cdn.jsdelivr.net/gh/netnr/cdn/libs/netnr-nav/1.1.2/netnrnav.css' rel='stylesheet' />
<script src='https://cdn.jsdelivr.net/gh/netnr/cdn/libs/netnr-nav/1.1.2/netnrnav.js' defer async></script>
        <link href="/css/global.css?v=NAI_hOr6ZSg5NjaPo94olMdf7kAXXyp9gYOiuK69lLE" rel="stylesheet" />
        <script src="/js/global.js?v=-UUx_lkaONxBXMxYH5RB2QtqMLBOuqV077SxjKI08E4"></script>
            <!--导航-->
            <button type="button" class="MenuToggle show-in-mobile btn btn-lg btn-warning ml-3 mt-3">
                <span class="fa fa-align-justify"></span>
            </button>
            <div class="netnrnav horizontal">
                <div class="netnrnav-wrapper">
                    <ul>
                        <li><a href="https://www.netnr.com" class="siteIcon"><img src="/favicon.ico" /> 首页</a></li>
                        <li><a href="https://www.netnr.com/gist/discover" title="代码片段"><span class="fa fa-fw fa-file-code-o"></span> Gist</a></li>
                        <li><a href="https://www.netnr.com/run/discover" title="在线运行代码"><span class="fa fa-fw fa-play"></span> Run</a></li>
                        <li><a href="https://www.netnr.com/doc" title="文档管理"><span class="fa fa-fw fa-book"></span> Doc</a></li>
                        <li><a href="https://www.netnr.com/draw/discover" title="绘制"><span class="fa fa-fw fa-paint-brush"></span> Draw</a></li>
                        <li><a href="/" title="ss.js.org"><span class="fa fa-fw fa-wrench"></span> 服务</a></li>
                        <li style="background-image: radial-gradient(ellipse, white, rgb(227, 248, 240))">
                            <!--标题-->
                                <a href='javascript:location.reload(false)' title="ZeroTier 管理">
                                    <svg class="titleicon"><use xlink:href="#p2p"></use></svg> ZeroTier
                                </a>
                        </li>
                        <li>
                            <a class="text-muted"><span class="fa fa-fw fa-ellipsis-h"></span></a>
                            <ul>
                                <li><a target="_blank" title="码云" href="https://gitee.com/netnr"><i class="fa fa-fw fa-git"></i> Gitee <sup><i class="fa small fa-external-link"></i></sup></a></li>
                                <li><a target="_blank" title="GitHub" href="https://github.com/netnr"><i class="fa fa-fw fa-github"></i> GitHub <sup><i class="fa small fa-external-link"></i></sup></a></li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        <div class="min300 mt-3">
            <div class="container-fluid">
    <div class="row">
        <div class="col-auto">
            <div class="input-group">
                <div class="input-group-prepend">
                    <span class="input-group-text">Token</span>
                </div>
                <input class="form-control" id="txtToken" placeholder="请粘贴 API token" maxlength="32" />
                <div class="input-group-prepend">
                    <span class="input-group-text">NetworkId</span>
                </div>
                <input class="form-control" id="txtNetworkId" placeholder="请粘贴 NetworkId" maxlength="16" />
                <div class="input-group-prepend">
                    <span class="input-group-btn">
                        <a class="btn btn-link" target="_blank" href="https://my.zerotier.com">ZeroTier</a>
                    </span>
                </div>
            </div>
        </div>
        <div class="col-md-12 mt-3" id="PGrid">
            <table id="table" class="text-nowrap"></table>
        </div>
    </div>
</div>

<link href='https://cdn.jsdelivr.net/npm/bootstrap-table@1.18.3/dist/bootstrap-table.min.css' rel='stylesheet' />
<script src='https://cdn.jsdelivr.net/npm/bootstrap-table@1.18.3/dist/bootstrap-table.min.js'></script>
<script src='https://cdn.jsdelivr.net/npm/bootstrap-table@1.18.3/dist/extensions/filter-control/bootstrap-table-filter-control.min.js'></script>


<script>
    var zt = {
        init: function () {
            $('#txtToken').on('input', function () {
                ss.ls.token = this.value;
                ss.lsSave();
                zt.getNetworkMember();
            }).val(ss.ls.token || "")

            $('#txtNetworkId').on('input', function () {
                if (this.value.length == 16 || this.value == "") {
                    ss.ls.networkId = this.value;
                    ss.lsSave();
                }
                zt.getNetworkMember();
            }).val(ss.ls.networkId || "")

            zt.getNetworkMember();

            $(window).resize(function () {
                zt.resize();
            })
        },

        /** 获取您至少具有读取权限的网络的所有成员 */
        getNetworkMember: function () {
            if (ss.ls.token && ss.ls.networkId && ss.ls.networkId.length == 16) {
                ss.loading();

                ss.ajax({
                    headers: {
                        Authorization: "bearer " + ss.ls.token
                    },
                    url: "https://my.zerotier.com/api/network/" + ss.ls.networkId + "/member",
                    dataType: 'json',
                    success: function (data) {
                        $('#table').bootstrapTable({
                            filterControl: true,
                            columns: [
                                {
                                    field: "online", title: "在线状态", sortable: true, filterControl: "select", formatter: function (value) {
                                        if (value == true) {
                                            return '✔'
                                        } else {
                                            return '✖'
                                        }
                                    }
                                },
                                { field: "nodeId", title: "节点ID", sortable: true, filterControl: "input" },
                                {
                                    field: "name", title: "名称", sortable: true, filterControl: "input", formatter: function (value, row) {
                                        if (row.description != "") {
                                            value += "（" + row.description + "）";
                                        }
                                        return value;
                                    }
                                },
                                {
                                    field: "managedIp", title: "托管IP", filterControl: "input", formatter: function (_value, row) {
                                        return row.config.ipAssignments.join('<br/>');
                                    }
                                },
                                {
                                    field: "noAutoAssignIps", title: "自动分配IP", filterControl: "select", formatter: function (_value, row) {
                                        return !row.config.noAutoAssignIps;
                                    }
                                },
                                { field: "physicalAddress", title: "公网IP", sortable: true, filterControl: "input" },
                                {
                                    field: "creationTime", title: "创建时间", filterControl: "input", formatter: function (_value, row) {
                                        return new Date(row.config.creationTime + 8 * 3600 * 1000).toISOString().replace("T", " ").substr(0, 19);
                                    }
                                },
                                {
                                    field: "lastOnline", title: "最后在线时间", filterControl: "input", formatter: function (value) {
                                        if (value != 0) {
                                            return new Date(value + 8 * 3600 * 1000).toISOString().replace("T", " ").substr(0, 19);
                                        }
                                        return "";
                                    }
                                },
                                {
                                    field: "authorized", title: "授权", sortable: true, filterControl: "select", formatter: function (_value, row) {
                                        return row.config.authorized;
                                    }
                                },
                                { field: "clientVersion", title: "客户端版本", sortable: true, filterControl: "select" }
                            ],
                            data: data,
                            onLoadSuccess: function () {
                                zt.resize();
                            }
                        });
                    },
                    error: function () {
                        jz.msg("载入失败")
                    },
                    complete: function () {
                        ss.loading(0);
                    }
                }, 0)
            }
        },

        resize: function () {
            $('#table').bootstrapTable('resetView', {
                height: $(window).height() - $('#PGrid').offset().top - 15
            });
        }
    }

    zt.init();
</script>
        </div>
</body>
</html>
